package 链表.easy;

import 链表.middle.YiSiEr;

/**
 * @author Lw中
 * @date 2020/9/22 16:08
 */
public class YiLuLing {

    /**
     * 相交链表
     */

    class ListNode {
        int val;
        ListNode next;
        ListNode(int x) {
            val = x;
            next = null;
        }
    }

    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {

        ListNode A = headA;
        ListNode B = headB;

        if (A == null || B == null) {
            return null;
        }
        while (A != B) {
            A = (A == null ? headB : A.next);
            B = (B == null ? headA : B.next);
        }
        return A;
    }

    public static void main(String[] args) {

    }

}
